<!--%import("css/member_admin.css")-->
<!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 
이 부분 어디에 쓰이는지?? dock 효과 적용안되는듯 이 부분 활성화되면-->
<div style="border-bottom:2px solid #ccc; margin:10px 0px;"><img src="layouts/yamnyam_shop_layout/images/4-3.png" width="300" height="36"></div>
	<div class="mypage_middle" align="center">
	{@
		// 다시 시작된 나의 노가다
		// $count 는 총 데이터 갯수
		// $extra_var[게시물순서][0~12번까지 extra_var 순서대로 들어가있음]

		// $count_product[n] : n번째 게시물의 상품수
		// $product[n][m] : n번째 게시물의 m번째 상품정보
		$storeName = "";//$logged_info->nick_name; // 나중에 값만 유저아이디로 바꾸면 해당 유저(상점)의 합계만 다 더해서 챠트로 뿌림

	    $oDB = &DB::getInstance();

		$str = $start_day."000000";
		$str2 = $end_day."400000";
		
		$intSyear = substr($start_day,0,4);
		$intSmonth = substr($start_day,4,2);
		$intSday = substr($start_day,6,2);
		$intEyear = substr($end_day,0,4);
		$intEmonth = substr($end_day,4,2);
		$intEday = substr($end_day,6,2);
		$intStime = mktime(0,0,0,$intSmonth, $intSday, $intSyear);
		$intEtime = mktime(0,0,0,$intEmonth, $intEday, $intEyear);
		$strDay = ($intEtime - $intStime)/86400;
		// 기간일수 구하기
		$strDaycnt = floor($strDay)+1;
}
	<!--@if($unit=="day")-->
		{@// 그래프 타이틀
			$graph_title = "<b>< " . $start_day . " ~ " . $end_day . " ></b>";
		}
	<!--@elseif($unit=="month")-->
		{@// 그래프 타이틀
			$graph_title = "<b>< " . $intSyear."/1월 ~ " . $intEyear . "/12월 ></b>";
			$str = $intSyear."0101000000";
			$str2 = $intEyear."1231400000";
		}
	<!--@endif-->

{@		
		    
	    $result = $oDB->_query("SELECT b.value,b.var_idx,regdate,title,a.document_srl FROM yman_document_extra_vars as b INNER JOIN yman_documents as a on b.document_srl=a.document_srl where b.document_srl in (SELECT a.document_srl FROM yman_document_extra_vars as b INNER JOIN yman_documents as a on b.document_srl=a.document_srl where b.module_srl=76 and b.var_idx=1 and regdate > $str and regdate < $str2) order by regdate desc;");

	    $output = $oDB->_fetch($result);
		$count = count($output)/12;

		$i=0;
		$j=0;

		$price=0;
	}
	<div style="width:100%;">	
		<div id="divSalesGraph" style="width:700px;border:2px solid #ccc; padding:20px;" align="center">
			<div align='center'>{$graph_title}</div>
			<table width='100%' border='0'>
			</table>
		</div>
	</div>
	
	<!-- 쿼리 결과를 저장 -->
		<!--@foreach($output as $key => $val)-->
			{@
				$extra_var[$i][$val->var_idx-1] = $val->value;
				$extra_var[$i][regdate] = $val->regdate;
				$extra_var[$i][title] = $val->title;
				$extra_var[$i][document_srl] = $val->document_srl;
				$query_str .= "'".$val->document_srl."',";
				$j++;
			   	if($j%12 == 0)$i++;
			  }
			 
		<!--@endforeach-->

	
	<!-- 각 상품정보를 product에 저장 --> 
	
			<!--@for($i=0; $i< $count; $i++)-->
			
			{@
				$product_data = $extra_var[$i][0];
				$product_data2[$i] = explode("&&", $product_data);
				$count_product[$i] = count($product_data2[$i])-1;
				$delivery[$i] = explode("|", $extra_var[$i][2]);
				$product[$i][push] = array();
			}
			
				<!--@for($j=0; $j< $count_product[$i]; $j++)-->
					{@ 
						$product[$i][$j] = explode("|", $product_data2[$i][$j]);
					}
					
					<!--//if($product[$i][$j][1] == $storeName)-->
	
							<!--@if($detail != "")-->
								{@ $detail .= "<br>";}
							<!--@endif-->
							
						{@
							$product[$i][delivery] = $delivery[$i][$j];
							$price += $product[$i][$j][4];
							$detail .= $product[$i][$j][2]." * ".$product[$i][$j][3]." = ".number_format($product[$i][$j][4])."원";
							array_push($product[$i][push],$j);
						}
						<!--@if($unit=="day")-->
							{@
								$sum[substr($extra_var[$i][regdate],0,8)] += $price;
							}
						<!--@elseif($unit=="month")-->
							{@// 그래프 타이틀
								$sum[substr($extra_var[$i][regdate],0,6)] += $price;
							}
						<!--@endif-->

					<!--//endif-->
				<!--@end-->
							
				
							
				
				{@
					$price=0;
					$detail="";
				}
			<!--@end-->
		
	{@ 
		$max= max($sum);
		$total= array_sum($sum);
		$count_num = count($sum);
	}
	

	<script type="text/javascript">
		$(document).ready(function(){
			<!--@if($unit == "day")-->
				<!--@for($z=0; $z < $strDaycnt; $z++)-->
					$("#divSalesGraph table").append("<tr><td width='80' align='right' style='padding-right:5px;'>{date("Y/m/d",strtotime($start_day."+".$z."day"))}</td><td><div style='background:blue;width:{($sum[date("Ymd",strtotime($start_day."+".$z."day"))]+0)/$max*500}px;float:left'>&nbsp;</div>{number_format($sum[date("Ymd",strtotime($start_day."+".$z."day"))]+0)}원</td></tr>");
				<!--@end-->
			<!--@elseif($unit=="month")-->
				<!--@for($z=1; $z <= 12; $z++)-->
				{@$mon = substr("0".$z, -2, 2);}
					$("#divSalesGraph table").append("<tr><td width='80' align='right' style='padding-right:5px;'>{$intSyear}/{$z}월</td><td><div style='background:blue;width:{($sum[$intSyear.$mon]+0)/$max*500}px;float:left'>&nbsp;</div>{number_format($sum[$intSyear.$mon]+0)}원</td></tr>");
				<!--@end-->
				
				
			<!--@endif-->
			$("#divSalesGraph").append("<div align='right'><b>총매출 : <span style='color:red'>{number_format($total)}</span>원</b></div>");
		});
	</script>

	<div style="margin-top:8px; padding-top:20px; width:100%; ">
		<center>
		<!--@for($i=1;$i<=date('n');$i++)-->
			{@$mon = substr("0".$i, -2, 2);}
			<a href={$request_uri}?mid=shop_main&act=dispMemberAdminSalesGraph&start_day=2011{$mon}01&end_day=2011{$mon}31>{$i}월</a> 
		<!--@end-->
		 <a href={$request_uri}?mid=shop_main&act=dispMemberAdminSalesGraph&start_day=20110101&end_day=20111231&unit=month>[2011년월간통계]</a> <br>
		</center>
	</div>
	</div>
	
	<div class="mypage_bottom"></div>	
